package com.huaxin.hxcloud.work;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.huaxin.common.Entity.SVGViewDTO;
import com.huaxin.hxcloud.R;

import java.util.List;

/**
 * @author songxf
 *         created at 2017/7/24 11:25
 * @desc 显示多张SVG 图 adapter
 */

public class HxSvgShowAdapter extends BaseAdapter {

    private Context context;
    List<SVGViewDTO.SvgListBean> mSvgListBean;
    public int mPosition;

    public HxSvgShowAdapter(Context context, List<SVGViewDTO.SvgListBean> svgListBean) {
        this.context = context;
        this.mSvgListBean = svgListBean;
    }

    public void setPosition(int mPosition) {
        this.mPosition = mPosition;
    }

    @Override
    public int getCount() {
        return mSvgListBean.size();
    }

    @Override
    public Object getItem(int position) {
        return mSvgListBean.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = LayoutInflater.from(context).inflate(R.layout.item_svg, null);
        TextView tv = (TextView) convertView.findViewById(R.id.tv);
        mPosition = position;
        tv.setText(mSvgListBean.get(position).getViewName());
        if (position == mPosition) {
            //convertView.setBackgroundResource(R.drawable.tongcheng_all_bg01);
        } else {
            convertView.setBackgroundColor(Color.parseColor("#f4f4f4"));
        }
        return convertView;
    }

    interface OnItemClickListener {
        void onItemClick(int position);
    }

    private OnItemClickListener mItemClickListener;

    void setItemClickListStenre(OnItemClickListener itemClickListener) {
        this.mItemClickListener = itemClickListener;
    }
}
